package com.admin.education.models;

import com.admin.education.repositories.Identifiable;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
import java.util.List;

@Entity
@Table(name = "subjects")
@EntityListeners(AuditingEntityListener.class)
@Data
public class Subjects  implements Serializable,Identifiable {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    private long id;
    @NotBlank
    @Length(max = 64)
    @Column(name = "name")
    private String name;
    @OneToMany(mappedBy = "subjects")
    @JSONField(serialize=false)
    private List<Questions> questions;
    @OneToMany(mappedBy = "subjects")
    @JSONField(serialize=false)
    private List<TemplateQuestions> templateQuestions;
    @JSONField(serialize=false)
    @OneToMany(mappedBy = "subjects")
    private List<UserAnswerSheetQuestion> userAnswerSheetQuestions;
}
